#include "AndQuery.h"
#include "QueryResult.h"


QueryResult AndQuery::eval(const TextQuery& text) const{
    QueryResult left = lhs.eval(text),right = rhs.eval(text);
    auto ret_idxs = make_shared<std::set<int>>();
    //将left和right集合的交集用迭代器写入ret集合中
    std::set_intersection(left.begin(),left.end(),right.begin(),right.end(),
    std::inserter(*ret_idxs,ret_idxs->begin()));
    return QueryResult(rep(),ret_idxs,left.get_file());
}